﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Vehicle.DAL
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Admin.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-08-26    Created by 杨光远 V1.00.0000
    /// 功能说明：Admin表数据层类（继承于数据层基类)
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public class Admin : DAL.Base_DAL, Vehicle.Interface.IAdmin
    {
        #region ---基本方法---
       /// <summary>
        /// 绑定页面Repeater控件
       /// </summary>
        /// <param name="Rept">Repeater控件对象</param>
       /// <param name="m_ComponentsInfo">通用实体对象</param>
        public void RepeaterBind(Repeater Rept, Model.ComponentsInfo m_ComponentsInfo)
        {

            Rept.DataSource = GetAllSearch(new Model.ComponentsInfo(m_ComponentsInfo.startIndex, m_ComponentsInfo.endIndex, "Admin", m_ComponentsInfo.condition, m_ComponentsInfo.result, m_ComponentsInfo.Tcondition, m_ComponentsInfo.Tresult, "A_ID")).DefaultView;
            Rept.DataBind();
        }
        /// <summary>
        /// 绑定页面DropDownList1控件
        /// </summary>
        /// <param name="drop">DropDownList1控件对象</param>
        public void DropDownListBind1(DropDownList drop)
        {

            drop.DataSource = GetModel(new Model.ComponentsInfo("Role", "R_ID")).DefaultView;
            drop.DataTextField = "R_Name";//显示的名称
            drop.DataValueField = "R_ID";//数据值
            drop.DataBind();
            drop.Items.Add(new ListItem("全部", "0"));
            drop.SelectedValue = "0";


        }
        /// <summary>
        /// 绑定页面DropDownList2控件
        /// </summary>
        /// <param name="drop">绑定页面DropDownList2控件对象</param>
        public void DropDownListBind2(DropDownList drop)
        {

            drop.DataSource = GetModel(new Model.ComponentsInfo("Role", "R_ID")).DefaultView;
            drop.DataTextField = "R_Name";//显示的名称
            drop.DataValueField = "R_ID";//数据值
            drop.DataBind();
        }

        /// <summary>
        /// 添加用户数据
        /// </summary>
        /// <param name="m_AdminInfo">实体对象</param>
        public void Add(Model.AdminInfo m_AdminInfo)
        {
            string SpName = "Admin_ADD";
            object[] _object = new object[] { 0, m_AdminInfo.A_LoginID, m_AdminInfo.A_PassWord, m_AdminInfo.A_Name, m_AdminInfo.R_ID, m_AdminInfo.A_IsDelete, m_AdminInfo.A_LastTime };
            SqlHelper.ExecuteNonQuery(SpName, _object);

        }
        /// <summary>
        /// 修改用户数据
        /// </summary>
        /// <param name="m_AdminInfo">实体对象</param>
        public void Update(Model.AdminInfo m_AdminInfo)
        {
            string SpName = "Admin_Update";
            object[] _object = new object[] { 0, m_AdminInfo.A_ID, m_AdminInfo.A_LoginID, m_AdminInfo.A_PassWord, m_AdminInfo.A_Name, m_AdminInfo.R_ID, m_AdminInfo.A_IsDelete, m_AdminInfo.A_LastTime };
            SqlHelper.ExecuteNonQuery(SpName, _object);
        }
        #endregion
    }
}
